//
//  MainController.m
//  N9Mi
//
//  Created by Sunshine on 2017/12/6.
//  Copyright © 2017年 Sunshine. All rights reserved.
//

#import "MainController.h"
#import "HomeC.h"
#import "CommunityC.h"
#import "ShoppingC.h"
#import "MyC.h"

@interface MainController ()

@end

@implementation MainController

- (void)viewDidLoad {
    [super viewDidLoad];
    //标题的大小和颜色设置
    [[UITabBarItem appearance]setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}forState:UIControlStateNormal];
    

    [[UITabBar appearance] setTintColor:[UIColor redColor]];
    //设定Tabbar的颜色
    [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
    
    
    HomeC *homeVC = [[HomeC alloc] init];
    [self addOneChlildVc:homeVC title:@"首页" imageName:@"tab_01_1.png" selectedImageName:@"tab_01_1.png"];
    CommunityC *commVC = [[CommunityC alloc]init];
    
    [self addOneChlildVc:commVC title:@"社区" imageName:@"tab_02_1.png" selectedImageName:@"tab_02_1.png"];
    
    ShoppingC *shopVC = [[ShoppingC alloc] init];
    [self addOneChlildVc:shopVC title:@"购物" imageName:@"tab_04_1.png" selectedImageName:@"tab_04_1.png"];
    
    MyC *myVC = [[MyC alloc] init];
    [self addOneChlildVc:myVC title:@"我的" imageName:@"tab_05_1.png" selectedImageName:@"tab_05_1.png"];
    
    
    
    
    
}


- (void)addOneChlildVc:(UIViewController *)childVc title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
    
    // 设置标题
    // 相当于同时设置了tabBarItem.title和navigationItem.title
    childVc.title = title;
    // 设置图标
    childVc.tabBarItem.image = [UIImage imageNamed:imageName];
    
    
    // 设置选中的图片
    childVc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImageName];
    
    //     添加为tabbar控制器的子控制器
    UINavigationController  *nav = [[UINavigationController alloc] initWithRootViewController:childVc];
    [self addChildViewController:nav];
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
